package com.ruoyi.yljf.controller.AppController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.security.annotation.Anonymous;
import com.ruoyi.yljf.domain.dto.AliPayDTO;
import com.ruoyi.yljf.service.IAlipayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName 用户充值controller
 * @Description
 * @Author wangpan
 * @Date 2025/3/17 10:46
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/pay")
public class AliPayController extends BaseController {

    @Autowired
    IAlipayService alipayService;


    @RequestMapping("/aliPay")
    public AjaxResult aliPay(AliPayDTO dto) throws Exception {
        dto.setUserId(getUserId());
        return AjaxResult.success(alipayService.aliPayByApp(dto));
    }

    @Anonymous
    @RequestMapping("/doAliPayCallBack")
    public void doAliPayCallBack(HttpServletRequest request) throws Exception {
        alipayService.doAliPayCallBack(request);
        System.out.println("回调成功!");
    }

    @Anonymous
    @RequestMapping("/doIosPayCallBack")
    public void doIosPayCallBack(HttpServletRequest request) throws Exception {
        alipayService.doAliPayCallBack(request);
        System.out.println("回调成功!");
    }
}
